﻿<UserControl x:Class="AphidUI.AphidRepl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xmlns:l="clr-namespace:AphidUI"
             d:DesignHeight="300" d:DesignWidth="500">
    <UserControl.Resources>
        <l:BoolFlipConverter x:Key="flipConverter" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="200" />
            <ColumnDefinition Width="300" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="20" />
            <RowDefinition x:Name="CodeRow" Height="Auto" MinHeight="32" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Menu Grid.ColumnSpan="2" VerticalAlignment="Center">
            <Menu.Resources>
                <Style TargetType="MenuItem">
                    <Setter Property="VerticalAlignment" Value="Center" />
                </Style>
                
            </Menu.Resources>
            <MenuItem x:Name="RunMenuItem" Header="Run (F5)"
                      Visibility="{Binding RunVisibility}"
                      IsEnabled="{Binding IsExecuting,Converter={StaticResource flipConverter}}"/>
            <MenuItem x:Name="StopMenuItem" Header="Stop"
                      Visibility="{Binding StopVisibility}"
                      IsEnabled="{Binding IsExecuting}"/>
            <MenuItem x:Name="ClearMenuItem" Header="Clear Console"
                      IsEnabled="{Binding IsExecuting,Converter={StaticResource flipConverter}}"/>
            <MenuItem x:Name="ResetMenuItem" Header="Reset"
                      IsEnabled="{Binding IsExecuting,Converter={StaticResource flipConverter}}"/>
            <RadioButton Content="Single Line" GroupName="Mode" 
                         IsEnabled="{Binding IsExecuting,Converter={StaticResource flipConverter}}"
                         Visibility="{Binding LineOptionVisibility}"
                         IsChecked="{Binding IsMultiLine,
                                             Mode=TwoWay,
                                             Converter={StaticResource flipConverter}}" />
            <RadioButton Content="Multi Line" GroupName="Mode" 
                         Visibility="{Binding LineOptionVisibility}"
                         IsEnabled="{Binding IsExecuting,Converter={StaticResource flipConverter}}"
                         IsChecked="{Binding IsMultiLine,Mode=TwoWay}" />
        </Menu>

        <!--<TextBox x:Name="ExpressionTextBox"
                 IsEnabled="{Binding IsExecuting,Converter={StaticResource flipConverter}}"
                 Margin="0,4,0,4" Grid.Row="1" Height="20" AcceptsReturn="False" 
                 VerticalContentAlignment="Center"
                 Visibility="{Binding ExpressionVisibility}"
                 Text="{Binding Code,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />-->

        <l:CodeTextBox x:Name="ExpressionTextBox"
                 IsEnabled="{Binding IsExecuting,Converter={StaticResource flipConverter}}"
                 Margin="0,4,0,4" Grid.Row="1" Height="20" AcceptsReturn="False" 
                 VerticalContentAlignment="Center"
                 Visibility="{Binding ExpressionVisibility}"
                 Text="{Binding Code,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />

        <!-- initial size hack -->
        <Rectangle Grid.Row="1" Height="120" Visibility="{Binding StatementsVisibility}" />
        <l:CodeTextBox x:Name="StatementsTextBox" Grid.Row="1" Margin="0,4,0,4" FontSize="12"
                       AcceptsReturn="true"
                       IsEnabled="{Binding IsExecuting,Converter={StaticResource flipConverter}}"
                       Visibility="{Binding StatementsVisibility}"
                       Text="{Binding Code,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                       SizeChanged="StatementsTextBox_SizeChanged" />

        <l:CodeViewer Grid.Row="2" x:Name="OutputTextBox2"
                      ScrollViewer.HorizontalScrollBarVisibility="Auto" 
                      ScrollViewer.VerticalScrollBarVisibility="Auto" />

        <GridSplitter Grid.Row="1" Height="4" Background="Transparent"
                      VerticalAlignment="Bottom" HorizontalAlignment="Stretch"
                      Visibility="{Binding StatementsVisibility}" />

        <GridSplitter Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" Width="4"
                      Background="Transparent"
                      VerticalAlignment="Stretch" HorizontalAlignment="Left" />

        <l:AphidWatch Margin="4,4,0,0" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" />
    </Grid>
</UserControl>
